<?php
declare (strict_types=1);

namespace common\listener;


use app\logic\AuthLogic;

class AfterLoginListener
{
    /**
     * @param $event
     * @return bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function handle($event)
    {
        if (isset($event['admin_id']) && !empty($event['admin_id'])) {
            $adminId = $event['admin_id'];
        } else {
            return false;
        }

        $authLogic = new AuthLogic();
        $adminAllMenuId = $authLogic->getUserExt($adminId);
        cache('Admin-Menu-ids:' . $adminId, $adminAllMenuId);
        return true;
    }
}